package com.sinoglobal.sinostore.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.lidroid.xutils.BitmapUtils;
import com.sinoglobal.sinostore.R;
/**
 * 
* @title: SecondKillAdapter.java 
* @package com.chiliring.sinostore.adapter 
* @description: TODO(秒杀商品Adapter) 
* @author LK
* @date 2015-1-13 上午11:19:52
 */
public class SecondKillAdapter extends BaseAdapter {
	private Context context;
	private ArrayList<String> data;
	String imgHostUrl;
	BitmapUtils bitmapUtils;
	public SecondKillAdapter(Context context,ArrayList<String> data){
		this.context = context;
		this.data = data;
		bitmapUtils=new BitmapUtils(context);
		bitmapUtils.configDefaultLoadFailedImage(R.drawable.shop_defaultimghome_content_img);
		bitmapUtils.configDefaultLoadingImage(R.drawable.shop_defaultimghome_content_img);
	}
    public void setImgHostUrl(String imgHostUrl) {
		this.imgHostUrl = imgHostUrl;
		notifyDataSetChanged();
	}
	@Override
	public int getCount() {
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		return data.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(null == convertView){
			convertView = LayoutInflater.from(context).inflate(R.layout.shop_item_srcond_kill, null);
		}
		String img = data.get(position);
		ImageView imSecondKillImg = ViewHolder.getViewById(convertView, R.id.im_second_kill_img);
		bitmapUtils.display(imSecondKillImg, imgHostUrl+img);
//		TextView tvDisCountPrice = ViewHolder.getViewById(convertView, R.id.tv_discount_price);
//		TextView tvPrice = ViewHolder.getViewById(convertView, R.id.tv_price);
//		tvPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
		return convertView;
	}

}
